<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Web Solutions
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2006/04/11 20:58:15 $)
// $RCSfile: news.php,v $ : $Revision: 1.8 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================

if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

/**
* News Module
*/
class news {

	/**
	* Constructor to register any events, sections
	*/
	function news() {
		global $_SWIFT, $events;

		$events->registerEventModuleSWIFT(MODULE_NEWS, $this);

		// Staff CP
		$events->registerEvent(EVENT_STAFF, MODULE_NEWS, "managenews");
		$events->registerEvent(EVENT_STAFF, MODULE_NEWS, "managesubscribers");
		$events->registerEvent(EVENT_STAFF, MODULE_NEWS, "insertnews");
		$events->registerEvent(EVENT_STAFF, MODULE_NEWS, "importexport");
		$events->registerEvent(EVENT_STAFF, MODULE_NEWS, "editnews");
		$events->registerEvent(EVENT_STAFF, MODULE_NEWS, "editsubscriber");
		$events->registerEvent(EVENT_STAFF, MODULE_NEWS, "comments");
		$events->registerEvent(EVENT_STAFF, MODULE_NEWS, "viewnews");

		// RSS
		$events->registerEvent(EVENT_RSS, MODULE_NEWS, "view");

		// Support Center
		$events->registerEvent(EVENT_CLIENT, MODULE_NEWS, "view");
		$events->registerEvent(EVENT_CLIENT, MODULE_NEWS, "subscribe");
		$events->registerEvent(EVENT_CLIENT, MODULE_NEWS, "unsubscribe");
		$events->registerEvent(EVENT_CLIENT, MODULE_NEWS, "viewnews");
		$events->registerEvent(EVENT_CLIENT, MODULE_NEWS, "pdfexport");

		$eventaction = $events->eventdata["eventaction"];
	}

	/**
	* Destructor, called to unregister any events etc
	*/
	function _news() {
	}

	/*
	* Call back function
	*/
	function _eventcallback($eventtype, $eventaction)
	{
		global $_SWIFT, $interface, $template, $departments, $staffauth, $module, $grid, $xml, $staff, $settings, $dbCore, $events, $session, $loginshare, $cookie, $errormessage, $infomessage, $permissions, $mimelist;

		if ($eventtype == EVENT_STAFF && ($eventaction == "managenews" || $eventaction == "insertnews" || $eventaction == "editnews" || $eventaction == "viewnews")) {
			require_once ("./modules/news/staff_news.php");
			return true;
		} else if ($eventtype == EVENT_CLIENT && ($eventaction == "view" || $eventaction == "viewnews" || $eventaction == "subscribe" || $eventaction == "unsubscribe" || $eventaction == "pdfexport")) {
			require_once ("./modules/news/client_news.php");
			return true;
		} else if ($eventtype == EVENT_STAFF && ($eventaction == "managesubscribers" || $eventaction == "editsubscriber" || $eventaction == "importexport")) {
			require_once ("./modules/news/staff_subscribers.php");
			return true;
		} else if ($eventtype == EVENT_RSS && ($eventaction == "view")) {
			require_once ("./modules/news/rss_view.php");
			return true;
		} else if ($eventtype == EVENT_STAFF && ($eventaction == "comments")) {
			require_once ("./modules/news/staff_comments.php");
			return true;
		}
		

		return false;
	}
}
?>